<template>

  <div class="table-container">
    <catch-table :form-create="formCreate" v-bind="table"/>

    <!-- 详细信息 -->
    <el-dialog title="详细信息" :visible.sync="dialogVisible" width="60%" :before-close="handleClose">
      <el-descriptions border>
        <el-descriptions-item label="项目名">{{ e.project_name }}</el-descriptions-item>
        <el-descriptions-item label="项目地点">{{ e.project_city_name }}{{ e.project_city_address }}</el-descriptions-item>
        <el-descriptions-item label="项目工期要求">{{ e.project_time }}</el-descriptions-item>
        <el-descriptions-item label="项目优势">{{ e.project_you_shi }}</el-descriptions-item>
        <el-descriptions-item label="加急">{{ e.need_jia_ji_name }}</el-descriptions-item>
        <el-descriptions-item label="审核状态">{{ e.status_name }}</el-descriptions-item>
        <el-descriptions-item label="审核备注">{{ e.status_note }}</el-descriptions-item>
      </el-descriptions>

      <div v-if="e.status == 1" style="margin: 30px;">
        <el-input type="textarea" :rows="6" placeholder="备注" v-model="e.status_note">
        </el-input>
        <div style="display: flex;justify-content: center;margin-top: 20px">
          <el-button type="danger" @click="statusChange(e.id,3)">拒绝</el-button>
          <el-button type="primary" style="margin-left: 150px;" @click="statusChange(e.id,2)">通过</el-button>
        </div>
      </div>

    </el-dialog>
  </div>
</template>

<script>
import renderTable from '@/views/render-table-form'

export default {
  mixins: [renderTable],
  data() {
    return {
      need_audit: 1,
      status_note: '',
      tableFrom: '',
      e: { status_note: '' },
      dialogVisible: false
    }
  },
  methods: {
    beforeSubmit(row) {
      if (row.form.parent_id instanceof Array) {
        row.form.parent_id = row.form.parent_id.length > 0 ? row.form.parent_id.pop() : 0
      }
      return row
    },
    handleView(e) {
      this.e = e
      this.dialogVisible = true
    },

    statusChange(id, status) {
      this.$http({
        url: '/Need/audit',
        method: 'POST',
        data: { id: id, status: status }
      }).then(r => {
        this.dialogVisible = false        
        this.$message.success('操作成功')
        this.$refs[this.table.ref].getList()
      })
    },

    zidingyi(e) {
      console.log(e)
    }
  }

}
</script>
